package com.sicheng.lc.周赛.分类.模拟;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/6/23 14:30
 */
public class 找到最接近0的数字 {
    //https://leetcode.cn/problems/find-closest-number-to-zero/
    public int findClosestNumber(int[] nums) {
        int min = (int) 1e5;
        int max = -min;
        for (int num : nums) {
            if (Math.abs(num) <= min) {
                min = Math.abs(num);
                max = -num == max ? Math.max(-num, num) : num;
            }
        }
        return max;
    }

    public static void main(String[] args) {

    }
}
